﻿using Db4objects.Db4o;

namespace DataAccess
{

    /// <summary>
    /// Activate action class.
    /// </summary>
    class ActivateAction : IUpdateAction
    {

        /// <summary>
        /// The object to be activated.
        /// </summary>
        private object objectToActivate;

        /// <summary>
        /// The depth of the activation in the object graph.
        /// </summary>
        private int activateDepth;


        /// <summary>
        /// DeactivateAction constructor.
        /// </summary>
        /// <param name="objectToActivate">The object to be deactivated</param>
        /// <param name="activateDepth">The depth of the deactivation in the object graph</param>
        public ActivateAction(object objectToActivate, int activateDepth)
        {
            this.objectToActivate = objectToActivate;
            this.activateDepth = activateDepth;
        }


        /// <summary>
        /// Performs the activation action against the database.
        /// </summary>
        /// <param name="db">The database handle</param>
        public void PerformUpdate(IObjectContainer db)
        {
            db.Activate(objectToActivate, activateDepth);
        }

    }

}